/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.panels.datasets;

import java.awt.Color;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.table.TableModel;
import model.OpstiDomenskiObjekat;
import view.controllers.ControllerUI_DataSet;
import view.forms.OpstaEkranskaForma;

/**
 *
 * @author Jelena
 */
public class FrmDataSet extends javax.swing.JDialog  implements OpstaEkranskaForma {

    
    
    

    ControllerUI_DataSet controllerDataSet; 
    
    /**
     * CreaJFrametes new form PanelDataSet
     */
    public FrmDataSet(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
       
       
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtFieldDataSetTitle = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtAreaDescription = new javax.swing.JTextArea();
        jLabel11 = new javax.swing.JLabel();
        tfCreator = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        tfDonor = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        tfDateDS = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        tfAuthors = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        tfTitle = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        tfDate = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        tfLocation = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tfOtherInformation = new javax.swing.JTextArea();
        btnAddReference = new javax.swing.JButton();
        jScrollPane5 = new javax.swing.JScrollPane();
        listReferences = new javax.swing.JList();
        jLabel16 = new javax.swing.JLabel();
        btnUpdate = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("DataSet");
        setBackground(new java.awt.Color(204, 204, 255));
        setBounds(new java.awt.Rectangle(100, 100, 700, 510));
        setFont(new java.awt.Font("Agency FB", 2, 10)); // NOI18N
        getContentPane().setLayout(null);

        jLabel2.setText("DataSet Title: ");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(0, 20, 100, 14);

        jLabel3.setText("DataSet Description: ");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(0, 50, 102, 14);
        getContentPane().add(txtFieldDataSetTitle);
        txtFieldDataSetTitle.setBounds(120, 10, 540, 30);

        txtAreaDescription.setColumns(20);
        txtAreaDescription.setRows(5);
        jScrollPane1.setViewportView(txtAreaDescription);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(120, 50, 539, 80);

        jLabel11.setText("Creator:");
        getContentPane().add(jLabel11);
        jLabel11.setBounds(0, 150, 100, 14);
        getContentPane().add(tfCreator);
        tfCreator.setBounds(120, 140, 540, 30);

        jLabel12.setText("Donor:");
        getContentPane().add(jLabel12);
        jLabel12.setBounds(0, 180, 100, 14);
        getContentPane().add(tfDonor);
        tfDonor.setBounds(120, 180, 540, 30);

        jLabel13.setText("Date (please insert date in format MM/dd/yyyy):");
        getContentPane().add(jLabel13);
        jLabel13.setBounds(0, 220, 346, 14);

        tfDateDS.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tfDateDSFocusLost(evt);
            }
        });
        getContentPane().add(tfDateDS);
        tfDateDS.setBounds(370, 220, 281, 30);

        jLabel4.setText("Author(s):");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(0, 260, 90, 14);
        getContentPane().add(tfAuthors);
        tfAuthors.setBounds(100, 250, 270, 30);

        jLabel9.setText("Title:");
        getContentPane().add(jLabel9);
        jLabel9.setBounds(0, 290, 90, 14);
        getContentPane().add(tfTitle);
        tfTitle.setBounds(100, 290, 270, 30);

        jLabel10.setText("Date:");
        getContentPane().add(jLabel10);
        jLabel10.setBounds(0, 324, 90, 20);
        getContentPane().add(tfDate);
        tfDate.setBounds(100, 330, 270, 20);

        jLabel15.setText("Location:");
        getContentPane().add(jLabel15);
        jLabel15.setBounds(0, 360, 90, 20);
        getContentPane().add(tfLocation);
        tfLocation.setBounds(100, 360, 270, 30);

        jLabel14.setText("Other information:");
        getContentPane().add(jLabel14);
        jLabel14.setBounds(0, 400, 89, 14);

        tfOtherInformation.setColumns(20);
        tfOtherInformation.setRows(5);
        jScrollPane4.setViewportView(tfOtherInformation);

        getContentPane().add(jScrollPane4);
        jScrollPane4.setBounds(100, 400, 273, 48);

        btnAddReference.setText("Add Reference");
        btnAddReference.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddReferenceActionPerformed(evt);
            }
        });
        getContentPane().add(btnAddReference);
        btnAddReference.setBounds(270, 460, 105, 23);

        jScrollPane5.setViewportView(listReferences);

        getContentPane().add(jScrollPane5);
        jScrollPane5.setBounds(394, 286, 261, 166);

        jLabel16.setText("References:");
        getContentPane().add(jLabel16);
        jLabel16.setBounds(400, 260, 210, 14);

        btnUpdate.setText("Update");
        btnUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUpdateActionPerformed(evt);
            }
        });
        getContentPane().add(btnUpdate);
        btnUpdate.setBounds(563, 460, 90, 23);
    }// </editor-fold>//GEN-END:initComponents

    private void btnAddReferenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddReferenceActionPerformed
        controllerDataSet.addReference();
    }//GEN-LAST:event_btnAddReferenceActionPerformed

    private void tfDateDSFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfDateDSFocusLost
        try {
            String dateS=getTfDateDS().getText().trim();
            Date date=null;
            if(dateS!=null && !dateS.equals("")){
                date = new SimpleDateFormat("MM/dd/yyyy").parse(dateS);
            }
        } catch (ParseException ex) {
            getTfDateDS().setBackground(Color.red);
        }

    }//GEN-LAST:event_tfDateDSFocusLost

    private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateActionPerformed
        controllerDataSet.updateDS();
    }//GEN-LAST:event_btnUpdateActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddReference;
    private javax.swing.JButton btnUpdate;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JList listReferences;
    private javax.swing.JTextField tfAuthors;
    private javax.swing.JTextField tfCreator;
    private javax.swing.JTextField tfDate;
    private javax.swing.JTextField tfDateDS;
    private javax.swing.JTextField tfDonor;
    private javax.swing.JTextField tfLocation;
    private javax.swing.JTextArea tfOtherInformation;
    private javax.swing.JTextField tfTitle;
    private javax.swing.JTextArea txtAreaDescription;
    private javax.swing.JTextField txtFieldDataSetTitle;
    // End of variables declaration//GEN-END:variables

    @Override
    public TableModel vratiModel() {
        return null;
    }

    @Override
    public Object[] vratiPocetneVrednosti() {
        return null;
    }

    @Override
    public int vratiSelektovaniRed() {
        return -1;
    }

    @Override
    public OpstiDomenskiObjekat kreirajObjekat() {
        return null;
    }

    /**
     * @return the txtAreaDescription
     */
    public javax.swing.JTextArea getTxtAreaDescription() {
        return txtAreaDescription;
    }

    /**
     * @return the txtFieldDataSetTitle
     */
    public javax.swing.JTextField getTxtFieldDataSetTitle() {
        return txtFieldDataSetTitle;
    }

    /**
     * @return the listReferences
     */
    public javax.swing.JList getListReferences() {
        return listReferences;
    }


    /**
     * @return the tfAuthors
     */
    public javax.swing.JTextField getTfAuthors() {
        return tfAuthors;
    }

    /**
     * @return the tfCreator
     */
    public javax.swing.JTextField getTfCreator() {
        return tfCreator;
    }

    /**
     * @return the tfDate
     */
    public javax.swing.JTextField getTfDate() {
        return tfDate;
    }

    /**
     * @return the tfDateDS
     */
    public javax.swing.JTextField getTfDateDS() {
        return tfDateDS;
    }

    /**
     * @return the tfDonor
     */
    public javax.swing.JTextField getTfDonor() {
        return tfDonor;
    }

    /**
     * @return the tfLocation
     */
    public javax.swing.JTextField getTfLocation() {
        return tfLocation;
    }

    /**
     * @return the tfOtherInformation
     */
    public javax.swing.JTextArea getTfOtherInformation() {
        return tfOtherInformation;
    }

    /**
     * @return the tfTitle
     */
    public javax.swing.JTextField getTfTitle() {
        return tfTitle;
    }

    public void setControllerDataSet(ControllerUI_DataSet controllerDataSet) {
        this.controllerDataSet = controllerDataSet;
    }

    public JButton getBtnUpdate() {
        return btnUpdate;
    }
    
    
}
